package jsyf.oa.web.report.expense;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.expense.ReportCostFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2018/4/4.
 */
@Api(value = "费用报销", description = "费用报销")
@Controller
@RequestMapping("/reportCost")
public class ReportCostController {

    @Resource
    private ReportCostFacade reportCostFacade;


    @RequestMapping(value = "/getForPersonalCostByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取个人费用报销明细(新)",
            notes = "获取个人费用报销明细(新)",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{userId:'201803130905434DA1A2841C3CACCEB4',dateTime:'2018-04-11'}",dataType = "String", paramType = "body")
    public void getForPersonalCostByUserIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData){
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForPersonalCostByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @RequestMapping(value = "/getForPersonalByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取个人费用报销明细",
            notes = "获取个人费用报销明细",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{userId:'201803130905434DA1A2841C3CACCEB4',dateTime:'2018-04-11',start:''}",dataType = "String", paramType = "body")
    public void getForPersonalByUserIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForPersonalByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @RequestMapping(value = "/getForDepartByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取部门费用报销明细",
            notes = "获取部门费用报销明细",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{userId:'201712162032474387FC7EAE66BEFF22',dateTime:'2018-04-11'}",dataType = "String", paramType = "body")
    public void getForDepartByUserIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForDepartByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @RequestMapping(value = "/getForDepartByDepartIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取部门费用报销明细",
            notes = "获取部门费用报销明细",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{departId:'2017121617594DCC86E158E6249B66D2',dateTime:'2018-04-11'}",dataType = "String", paramType = "body")
    public void getForDepartByDepartIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForDepartByDepartIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @RequestMapping(value = "/getForCompanyByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取公司费用报销明细",
            notes = "获取公司费用报销明细",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{userId:'2017121620364A45928497FB723F1090',dateTime:'2018-04-11'}",dataType = "String", paramType = "body")
    public void getForCompanyByUserIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForCompanyByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @RequestMapping(value = "/getForCompanyByCompanyIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取公司费用报销明细",
            notes = "获取公司费用报销明细",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{companyId:'2017121617474C0586950A72B2629E79',dateTime:'2018-04-11'}",dataType = "String", paramType = "body")
    public void getForCompanyByCompanyIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForCompanyByCompanyIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @RequestMapping(value = "/getForGroupByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取集团费用报销明细",
            notes = "获取集团费用报销明细",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{userId:'201711271733404C9DA1461F2421F828','dateTime':'2018-04-11'}",dataType = "String", paramType = "body")
    public void getForGroupByUserIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForGroupByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @RequestMapping(value = "/getForPersonalSumByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取费用名称和合计",
            notes = "获取费用名称和合计",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData",value = "{userId:'201711271733404C9DA1461F2421F828','dateTime':'2018-04-11'}",dataType = "String", paramType = "body")
    public void getForPersonalSumByUserIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = this.reportCostFacade.getForPersonalSumByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }
}